﻿@using GigaSite.Domain.Entities
@using GigaSite.Web.Classes
@using GigaSite.Web.Models
@{
    ViewBag.Title = "Визитки компаний";
    Layout = "../../../../Views/Shared/_Layout.cshtml";
    var category = (Category) ViewBag.category;
    IList<Category> childCategories = (IList<Category>)ViewBag.childCategories;
}

<div id="page-cards" class="page">
    @* Навигационная цепочка *@
    @Html.NavigationChain()
    
    @* Верхий тулбар *@
    <div class="topBar">
        <div class="add">
            @Html.ActionLink("Добавить свою визитку","UploadCard")
        </div>
    </div>
    
    @* Вкладки *@
    <div class="tabs">
        <ul class="nav nav-tabs">
            <li>@Html.ActionLink("Все","All")</li>
            <li class="active">@Html.ActionLink("Компании","Companies")</li>
            <li>@Html.ActionLink("Специалисты","Specialists")</li>
            <li>@Html.ActionLink("Самые популярные визитки","Popular")</li>
        </ul>
    </div>
    @* Строка поиска и фильтра *@
    @Html.Partial("ContainerSearch")
    
    @* Рекоммендации *@
    @Html.Partial("CardsRecommendations")
    
    <table width="100%">
        <tbody>
            <tr valign="top">
                @* Левая панель категорий *@
                @if (childCategories.Count > 0)
                {
                    ViewBag.itemsPerLine = 3;
                    <td class="leftPane">
                        @* Текущая категория *@
                        <div class="currentCategory">
                            @category.DisplayName
                        </div>
                        @* Дочерние категории *@
                        <div class="subCategories">
                            <ul>
                                @foreach (var sub in childCategories)
                                {
                                    <li>@Html.ActionLink(sub.DisplayName, "Companies", new { id = sub.Id }) <span class="itemsCount">@sub.GetBusinessCardsCount()</span></li>
                                }
                            </ul>
                        </div>
                    </td>
                }
                <td>
                    @* Контейнер *@
                    <div class="containerWrapper">
        
                        @* Сами визитки *@
                        <div class="cards" id="CompanyCards">
                            @{
                                Html.RenderAction("CardsView", new { filter = "company", categoryId = category.Id });
                            }
                        </div>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>
<script language="javascript" type="text/javascript" src="@Url.Content("~/Scripts/Common/ajaxItemsGrid.js")"></script>
<script language="javascript" type="text/javascript">
    var allCardsGrid = new AjaxItemsGridLoader($("#CompanyCards"), "@Url.Action("GetCards")", "company");
</script>